package tech.aistar.corejava.day15.pool;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * @Author: lya
 * @Description: 本类的作用描述:创建一个定长线程池，支持定时及周期性任务执行
 * @CreateDate: 2019/8/4
 * @Version: 1.0
 */
public class ScheduledThreadPoolDemo {
    public static void main(String[] args) {
        ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(2);

        scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
            @Override
            public void run() {
                System.out.println(Thread.currentThread().getName()+"正在执行!");
                                                               }
        },1,3, TimeUnit.SECONDS);

    }
}
